<?php

require_once ('BaseAjaxModule.php');

class FeedModule extends BaseAjaxModule {
	
	public function deleteFeedTask()	{
		$feed = new Model_Feed();
		$feed->id = $this->getParam('id');
		$userID = $this->getUser()->id;
		$this->view->result = $feed->deleteFeedForUser($userID);
	}
	
	public function loadFeedsTask()	{
		$id = $this->getParam('id');
		$page = $this->getParam('page', 0);
		$feed = new Model_Feed();
		$userID = $this->getUser()->id;
		if ($id == null)	{
			$this->view->result = $feed->getFriendFeeds($userID, $page, 10);
		} else {
			$this->view->result = $feed->getUserFeeds($id, $userID, $page, 10);
		}
	}
	
	public function postFeedTask()	{
		$txt = $this->getParam('txt');
		$feed = new Model_Feed();
		$userID = $this->getUser()->id;
		$feed->from_id = $userID;
		//FIXME: Get to_id from params
		$feed->to_id = null;
		$feed->content = $txt;
		$feed->is_story = 1;
		$feed->public_id = 1;
		$feed->type = 'feed';
		$this->view->result = $feed->add(); 
	}
}

?>